#define _CRT_SECURE_NO_WARNINGS 1
#include"SinglyList.h"

void test1()
{
	SLNode* phead = NULL;
	SLPustfront(&phead, 1);
	SLPustfront(&phead, 2);
	SLPustfront(&phead, 3);
	SLPustfront(&phead, 3);
	SLPustfront(&phead, 3);
	SLPustfront(&phead, 3);
	
	SLPrint(&phead);


	SLDestroy(&phead);
}

void test2()
{
	SLNode* phead = NULL;
	SLPustfront(&phead, 1);
	SLPustfront(&phead, 2);
	SLPustfront(&phead, 3);

	SLPrint(&phead);

	SLPopfront(&phead);
	SLPrint(&phead);

	SLPopfront(&phead);
	SLPrint(&phead);

	SLPopfront(&phead);
	SLPrint(&phead);


	SLDestroy(&phead);
}

void test3()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);
	SLPustBack(&plist, 4);
	SLPustBack(&plist, 5);

	SLPrint(&plist);


	SLDestroy(&plist);
}

void test4()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);

	SLPrint(&plist);

	SLPopBack(&plist);
	SLPrint(&plist);

	SLPopBack(&plist);
	SLPrint(&plist);

	SLPopBack(&plist);
	SLPrint(&plist);

	//SLPopBack(&plist);
	//SLPrint(&plist);


	SLDestroy(&plist);
}

void test5()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);
	SLPustBack(&plist, 4);
	SLPustBack(&plist, 5);
	SLPustBack(&plist, 6);

	SLPrint(&plist);

	SLNode* pos =  SLFind(&plist, 2);
	if (pos == NULL)
		exit(-1);

	SLInsert(&plist, pos, 20);
	SLPrint(&plist);

	pos = SLFind(&plist, 1);
	if (pos == NULL)
		exit(-1);

	SLInsert(&plist, pos, 50);
	SLPrint(&plist);

	pos = SLFind(&plist, 6);
	if (pos == NULL)
		exit(-1);

	SLInsert(&plist, pos, 90);
	SLPrint(&plist);

	SLDestroy(&plist);
}

void test6()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);
	SLPustBack(&plist, 4);
	SLPustBack(&plist, 5);
	SLPustBack(&plist, 6);

	SLPrint(&plist);

	SLNode* pos = SLFind(&plist, 1);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 2);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 3);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 4);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 5);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 6);
	if (pos == NULL)
		exit(-1);

	SLErase(&plist, pos);
	SLPrint(&plist);

	SLDestroy(&plist);
}

void test7()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);
	SLPustBack(&plist, 4);
	SLPustBack(&plist, 5);
	SLPustBack(&plist, 6);

	SLPrint(&plist);

	SLNode* pos = SLFind(&plist, 1);
	if (pos == NULL)
		exit(-1);

	SLInsertAfter(pos, 10);
	SLPrint(&plist);

	pos = SLFind(&plist, 2);
	if (pos == NULL)
		exit(-1);

	SLInsertAfter(pos, 20);
	SLPrint(&plist);

	pos = SLFind(&plist, 3);
	if (pos == NULL)
		exit(-1);

	SLInsertAfter(pos, 30);
	SLPrint(&plist);

	pos = SLFind(&plist, 6);
	if (pos == NULL)
		exit(-1);

	SLInsertAfter(pos, 60);
	SLPrint(&plist);


	SLDestroy(&plist);
}

void test8()
{
	SLNode* plist = NULL;
	SLPustBack(&plist, 1);
	SLPustBack(&plist, 2);
	SLPustBack(&plist, 3);
	SLPustBack(&plist, 4);
	SLPustBack(&plist, 5);
	SLPustBack(&plist, 6);

	SLPrint(&plist);

	SLNode* pos = SLFind(&plist, 1);
	if (pos == NULL)
		exit(-1);

	
	SLEraseAfter(pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 3);
	if (pos == NULL)
		exit(-1);

	SLEraseAfter(pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 5);
	if (pos == NULL)
		exit(-1);

	SLEraseAfter(pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 3);
	if (pos == NULL)
		exit(-1);

	SLEraseAfter(pos);
	SLPrint(&plist);

	pos = SLFind(&plist, 1);
	if (pos == NULL)
		exit(-1);

	SLEraseAfter(pos);
	SLPrint(&plist);

	//pos = SLFind(&plist, 1);
	//if (pos == NULL)
	//	exit(-1);

	//SLEraseAfter(pos);
	//SLPrint(&plist);


	SLDestroy(&plist);
}

int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	//test5();
	//test6();
	//test7();
	test8();

	return 0;
}